package com.hdax.dm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdax.dm.beans.item.comment;
import com.hdax.dm.dto.descDto.getCommentsDto;
import com.hdax.dm.mappers.desc.getCommentsMapper;
import com.hdax.dm.mapstucts.descMapper.getCommentsDtoMapper;
import com.hdax.dm.service.getCommentsService;
import com.hdax.dm.utils.response.CommonResponse;
import com.hdax.dm.utils.response.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class getCommentsServiceImpl extends ServiceImpl<getCommentsMapper, comment> implements getCommentsService {

    @Autowired
    private getCommentsDtoMapper getCommentsDtoMapper;

    @Override
    public CommonResponse<List<getCommentsDto>> getComments(Map<String, Integer> params) {
        Integer id = params.get("id");
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id",id);
        List<comment> lists = baseMapper.selectList(queryWrapper);
        List<getCommentsDto> dtos =getCommentsDtoMapper.toTargetList(lists);
        return ResponseUtil.returnSuccess(dtos);
    }
}
